from flask import Blueprint, request
from ..controllers.announcement import (
    create_announcement,
    get_announcements,
    get_announcement,
    update_announcement,
    delete_announcement
)

# 创建公告相关的蓝图
announcement_bp = Blueprint('announcement', __name__)

# 注册路由
# 注意：根据要求，这里不使用JWT认证

# 创建公告
@announcement_bp.route('/announcements/add', methods=['POST'])
def route_create_announcement():
    return create_announcement()

# 获取公告列表
@announcement_bp.route('/announcements/list', methods=['GET'])
def route_get_announcements():
    data = request.args.to_dict() or {}
    return get_announcements(data)

# 获取单个公告
@announcement_bp.route('/announcements/get', methods=['GET'])
def route_get_announcement():
    return get_announcement()

# 更新公告
@announcement_bp.route('/announcements/update', methods=['POST'])
def route_update_announcement():
    return update_announcement()

# 删除公告
@announcement_bp.route('/announcements/delete', methods=['POST'])
def route_delete_announcement():
    return delete_announcement()